Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
ufechner7
left a comment
There was a problem hiding this comment.
Where is smooth_norm3 defined?
And why do you want to use it in the first place?
There was a problem hiding this comment.
Pull request overview
Replaces the strict norm3/normalize3! helpers with smoothed variants (smooth_norm3(a) = sqrt(a·a + 1e-12), unconditional smooth_normalize3!) throughout the filament induced-velocity routines, the 2D bound velocity, calculate_results, find_center_of_pressure, and solve!'s force-direction normalization, and bumps the additive epsilon inside smooth_sqrt from 1e-30 to 1e-18. The intent is to remove singular NaN/Inf results at on-axis or zero-magnitude geometries.
Changes:
- Switch all filament
norm3/normalize3!call sites to the smoothed helpers and remove the explicitvel .= 0.0near-axis branches in the bound and semi-infinite trailing routines (the finite trailing routine retains it). - Update
calculate_results,find_center_of_pressure,calculate_velocity_induced_bound_2D!, andsolve!to use the smoothed helpers; loosensmooth_sqrtepsilon in the gamma update. - Adjust the semi-infinite filament "Point on Filament" test to expect
isfiniteinstead ofisnan, and relaxmoment_dist[1]tolerance in the body-aerodynamics test from1e-8to1e-7.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/filament.jl | Replaces norm3/normalize3! with smoothed versions, removes near-axis zeroing in bound and semi-infinite routines. |
| src/body_aerodynamics.jl | Uses smooth_norm3 in calculate_results and find_center_of_pressure, including in pre-existing zero-magnitude guards. |
| src/panel.jl | Switches the 2D bound induced velocity to smoothed norms. |
| src/solver.jl | Uses smooth_normalize3! for force-direction unit vectors and increases smooth_sqrt epsilon to 1e-18. |
| test/filament/test_semi_infinite_filament.jl | Updates singular-start-point expectation from NaN to finite. |
| test/body_aerodynamics/test_body_aerodynamics.jl | Relaxes moment_dist[1] tolerance to 1e-7. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -833,7 +833,7 @@ function calculate_results( | |||
| va_ref_vector[k] = va_ref_vector[k] / direction_norm * | |||
| reference_speed | |||
| end | |||
| va_ref_mag = norm3(va_ref_vector) | |||
| va_ref_mag = smooth_norm3(va_ref_vector) | |||
| va_ref_mag > 0.0 || throw(ArgumentError( | |||
| "Reference freestream magnitude must be positive.")) | |||
| va_ref_unit = body_aero.work_vectors[1] | |||
| @@ -843,7 +843,7 @@ function calculate_results( | |||
| end | |||
| dir_lift_ref = body_aero.work_vectors[2] | |||
| cross3!(dir_lift_ref, va_ref_vector, spanwise_direction) | |||
| dir_lift_ref_norm = norm3(dir_lift_ref) | |||
| dir_lift_ref_norm = smooth_norm3(dir_lift_ref) | |||
| dir_lift_ref_norm > 0.0 || throw(ArgumentError( | |||
| @inline function smooth_normalize3!(v) | ||
| n = smooth_norm3(v) | ||
| v[1] /= n; v[2] /= n; v[3] /= n | ||
| nothing | ||
| end |
| if nr1Xr0 / nr0 > epsilon | ||
| nr1Xr2 = norm3(r1Xr2) | ||
| nr1Xr2 = smooth_norm3(r1Xr2) | ||
| coeff = (gamma / (4π)) / (nr1Xr2^2) * dot3(r0, r1r2norm) | ||
| @inbounds for k in 1:3 | ||
| vel[k] = coeff * r1Xr2[k] | ||
| end | ||
| elseif nr1Xr0 / nr0 < 1e-12 * epsilon | ||
| vel .= 0.0 | ||
| else |
|
defined here. And I use it for auto diff differentiability at zero. |
No description provided.